import time
import jwt
# pip install pyjwt
# from python_jwt import jwt

ak = "ADtaChPg4aRBCPnAk8HTBG99prfNYYmG" # 填写access key
sk = "t3aT84rJErHaFeBgQMrprFd3fYY8QNf8" # 填写secret key

def encode_jwt_token(ak, sk):
    headers = {
        "alg": "HS256",
        "typ": "JWT"
    }
    payload = {
        "iss": ak,
        "exp": int(time.time()) + 1800, # 有效时间，此处示例代表当前时间+1800s(30min)
        "nbf": int(time.time()) - 5 # 开始生效的时间，此处示例代表当前时间-5秒
    }
    token = jwt.encode(payload, sk, headers=headers)
    return token

api_token = encode_jwt_token(ak, sk)
print(api_token) # 打印生成的API_TOKEN
